/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.WebIDE.ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author huy
 */
@Entity
@Table(name = "resources")
@NamedQueries({@NamedQuery(name = "Resources.findAll", query = "SELECT r FROM Resources r"), @NamedQuery(name = "Resources.findById", query = "SELECT r FROM Resources r WHERE r.id = :id"), @NamedQuery(name = "Resources.findByUrl", query = "SELECT r FROM Resources r WHERE r.url = :url")})
public class Resources implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "url")
    private String url;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "resources", fetch = FetchType.EAGER)
    private Collection<GroupsResources> groupsResourcesCollection;

    public Resources() {
    }

    public Resources(Integer id) {
        this.id = id;
    }

    public Resources(Integer id, String url) {
        this.id = id;
        this.url = url;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Collection<GroupsResources> getGroupsResourcesCollection() {
        return groupsResourcesCollection;
    }

    public void setGroupsResourcesCollection(Collection<GroupsResources> groupsResourcesCollection) {
        this.groupsResourcesCollection = groupsResourcesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Resources)) {
            return false;
        }
        Resources other = (Resources) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.WebIDE.ejb.entities.Resources[id=" + id + "]";
    }

}
